package org.tokaf.normalizer;

import org.openrdf.model.impl.URIImpl;
import org.tokaf.TopKElement;

/**
 * <p>
 * NormCzechFrequency normalizes Czech words for frequency .</p>
 * <p>Copyright (c) 2006</p>
 * @author Alan Eckhardt
 * @version 1.0
 */
public class NormCzechFrequency implements Normalizer {
	public NormCzechFrequency() {
	}

	public NormCzechFrequency(String userName) {
		this.userName = userName;
	}

	String userName;

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public double Normalize(Object o) {
		URIImpl a = (URIImpl) o;
		if (a == null)
			return 0;
		//Malo, Vubec, Porad, Prumerne
		if (a.getLocalName().toUpperCase().equals("PORAD"))
			return 1;
		if (a.getLocalName().toUpperCase().equals("HODNE"))
			return 0.7;
		if (a.getLocalName().toUpperCase().equals("PRUMERNE"))
			return 0.5;
		if (a.getLocalName().toUpperCase().equals("MALO"))
			return 0.1;
		if (a.getLocalName().toUpperCase().equals("VUBEC"))
			return 0.05;
		return 0;
	}

	public double Normalize(TopKElement te, int index) {
		return Normalize(te.getRatingObject(index));
	}

	/**
	 * compare
	 *
	 * @param o1 Object
	 * @param o2 Object
	 * @return int
	 */
	public int compare(Object o1, Object o2) {
		double a = Normalize(o1);
		double b = Normalize(o2);
		if (a < b)
			return 1;
		if (a > b)
			return -1;
		return 0;

	}

}
